<template>
  <div id="deduction_all">
    <div id="top_box">
      <el-card shadow="hover">
        <el-row>
          <el-col :span="22">
            <el-breadcrumb separator="/">
              <el-breadcrumb-item v-for="(item, index) in breadcrumb_array"><a @click="turnTo(item, index)">{{ item.name }}</a></el-breadcrumb-item>
            </el-breadcrumb>
          </el-col>
          <el-col :span="2">
            <el-button type="success" icon="el-icon-plus" v-if="depth != 1" @click="add" style="text-align: right;">新增</el-button>
          </el-col>
        </el-row>
      </el-card>
    </div>
    <div id="tree_box">
      <el-table
        :data="tableData"
        stripe
        border
        v-if="depth == 1"
        style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center">
        </el-table-column>
        <el-table-column
          label="规则">
          <template slot-scope="scope">
              <el-button type="text" size="mini" @click="open(scope.row)">{{ scope.row.catalogName }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="唯一标识"
          width="120">
          <template slot-scope="scope">
            {{ scope.row.id }}
          </template>
        </el-table-column>
        <el-table-column
          label="最大分值"
          width="100">
          <template slot-scope="scope">
            <div v-if="scope.row.catalogName != '违反纪律一票否决'">
              <span v-if="scope.row.maxScore != null">{{ scope.row.maxScore/100 }}</span>
              <span v-else>{{ scope.row.maxScore }}</span>
            </div>
            <div v-else>一票否决</div>
          </template>
        </el-table-column>
        <el-table-column
          label="默认分值"
          width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.minScore != null">{{ scope.row.minScore/100 }}</span>
            <span v-else>{{ scope.row.minScore }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="编辑"
          width="100"
          align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="edit(scope.row)">
              编辑</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-table
        :data="tableData"
        stripe
        border
        v-if="depth == 2"
        style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center">
        </el-table-column>
        <el-table-column
          label="规则">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="open(scope.row)">{{ scope.row.catalogName }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="唯一标识"
          width="120">
          <template slot-scope="scope">
            {{ scope.row.id }}
          </template>
        </el-table-column>
        <el-table-column
          label="最大分值"
          width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.maxScore != null">{{ scope.row.maxScore/100 }}</span>
            <span v-else>{{ scope.row.maxScore }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="默认分值"
          width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.minScore != null">{{ scope.row.minScore/100 }}</span>
            <span v-else>{{ scope.row.minScore }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="类型"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.optFlg == '+'">加分项</span>
            <span v-else-if="scope.row.optFlg == '-'">扣分项</span>
            <span v-else>加分和扣分项</span>
          </template>
        </el-table-column>
        <el-table-column
          label="编辑"
          width="200"
          align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="edit(scope.row)">
              编辑</el-button>
            <el-button
              type="danger"
              size="mini"
              @click="del(scope.row)">
              删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-table
        :data="tableData"
        stripe
        border
        v-if="depth == 3"
        style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center">
        </el-table-column>
        <el-table-column
          label="扣分项">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="open(scope.row)">{{ scope.row.gradeItem }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="唯一标识"
          width="120">
          <template slot-scope="scope">
            {{ scope.row.id }}
          </template>
        </el-table-column>
<!--        <el-table-column-->
<!--          label="最大分值"-->
<!--          width="100">-->
<!--          <template slot-scope="scope">-->
<!--            <span v-if="scope.row.maxScore != null">{{ scope.row.maxScore/100 }}</span>-->
<!--            <span v-else>{{ scope.row.maxScore }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          label="默认分值"-->
<!--          width="100">-->
<!--          <template slot-scope="scope">-->
<!--            <span v-if="scope.row.minScore != null">{{ scope.row.minScore/100 }}</span>-->
<!--            <span v-else>{{ scope.row.minScore }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column
          label="类型"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleType == 'exe'">判断</span>
            <span v-else-if="scope.row.ruleType == 'input'">输入</span>
            <span v-else>选择</span>
          </template>
        </el-table-column>
        <el-table-column
          label="填报周期"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.cycle == 'cycle'">加分项</span>
            <span v-else-if="scope.row.cycle == 'month'">扣分项</span>
            <span v-else-if="scope.row.cycle == 'week'">平均分</span>
            <span v-else></span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核部门"
          width="120">
          <template slot-scope="scope">
            {{ scope.row.gradeByName }}
          </template>
        </el-table-column>
        <el-table-column
          label="编辑"
          width="200"
          align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="edit(scope.row)">
              编辑</el-button>
            <el-button
              type="danger"
              size="mini"
              @click="del(scope.row)">
              删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-table
        :data="tableData"
        stripe
        border
        v-if="depth == 4"
        style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center">
        </el-table-column>
        <el-table-column
          label="细则">
          <template slot-scope="scope">
            {{ scope.row.optionName }}
          </template>
        </el-table-column>
        <el-table-column
          label="唯一标识"
          width="120">
          <template slot-scope="scope">
            {{ scope.row.optionId }}
          </template>
        </el-table-column>
        <el-table-column
          label="填报类型"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleType == 'exe'">判断</span>
            <span v-else-if="scope.row.ruleType == 'input'">输入</span>
            <span v-else>选择</span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核类型"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.optFlg == '+'">加分项</span>
            <span v-else-if="scope.row.optFlg == '-'">扣分项</span>
            <span v-else>平均分</span>
          </template>
        </el-table-column>
        <el-table-column
          label="分值"
          width="100">
          <template slot-scope="scope">
            {{ scope.row.score/100 }}
          </template>
        </el-table-column>
        <el-table-column
          label="计分方式"
          width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.countType == 'sum'">求和</span>
            <span v-else>平均分</span>
          </template>
        </el-table-column>
        <el-table-column
          label="编辑"
          width="200"
          align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="edit(scope.row)">
              编辑</el-button>
            <el-button
              type="danger"
              size="mini"
              @click="del(scope.row)">
              删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <div v-if="dialogVisible">
        <el-dialog
          :title="dialogTitle"
          :visible.sync="dialogVisible"
          width="30%">
          <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
            <el-form-item label="扣分项名称" prop="catalogName" v-if="depth == 1">
              <el-input v-model="ruleForm.catalogName" placeholder="请输入扣分项名称" readonly></el-input>
            </el-form-item>
            <el-form-item label="扣分项名称" prop="catalogName" v-if="depth == 2">
              <el-input v-model="ruleForm.catalogName" placeholder="请输入扣分项名称"></el-input>
            </el-form-item>
            <el-form-item label="扣分项名称" prop="gradeItem" v-if="depth == 3">
              <el-input v-model="ruleForm.gradeItem" placeholder="请输入扣分项名称"></el-input>
            </el-form-item>
            <el-form-item label="扣分项名称" prop="optionName" v-if="depth == 4">
              <el-input v-model="ruleForm.optionName" placeholder="请输入扣分项名称"></el-input>
            </el-form-item>
            <el-form-item label="填报类型" prop="ruleType" v-if="depth == 3">
              <el-select v-model="ruleForm.ruleType" placeholder="请选择考核类型">
                <el-option label="判断" value="exe"></el-option>
                <el-option label="选择" value="option"></el-option>
                <el-option label="输入" value="input"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="填报周期" prop="cycle" v-if="depth == 3">
              <el-select v-model="ruleForm.cycle" placeholder="请选择填报周期">
                <el-option label="学期" value="cycle"></el-option>
                <el-option label="月" value="month"></el-option>
                <el-option label="周" value="week"></el-option>
                <el-option label="无" value="null"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="考评部门" prop="gradeBy" v-if="depth == 3">
              <el-select v-model="ruleForm.gradeBy" placeholder="请选择考评部门">
                <el-option v-for="item in gradeByOption" :label="item.key" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="考核类型" prop="optFlg" v-if="depth == 2">
              <el-select v-model="ruleForm.optFlg" placeholder="请选择考核类型">
                <el-option label="加分和扣分项" value="#"></el-option>
                <el-option label="加分项" value="+"></el-option>
                <el-option label="扣分项" value="-"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="考核类型" prop="optFlg" v-if="depth == 4">
              <el-select v-model="ruleForm.optFlg" placeholder="请选择考核类型">
                <el-option label="加分项" value="+"></el-option>
                <el-option label="扣分项" value="-"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="最大分值" prop="maxScore" v-if="depth == 1 || depth == 2">
              <el-input v-model="ruleForm.maxScore" placeholder="请输入最大分值"></el-input>
            </el-form-item>
            <el-form-item label="默认分值" prop="minScore" v-if="depth == 1 || (ruleForm.optFlg != '#' && depth == 2)">
              <el-input v-model="ruleForm.minScore" placeholder="请输入默认分值"></el-input>
            </el-form-item>
            <el-form-item label="分 值" prop="score" v-if="depth == 4">
              <el-input v-model="ruleForm.score" placeholder="请输入分值"></el-input>
            </el-form-item>
            <el-form-item label="计分方式" prop="countType" v-if="depth == 4">
              <el-select v-model="ruleForm.countType" placeholder="请选择考核类型">
                <el-option label="求和" value="sum"></el-option>
                <el-option label="平均分" value="avg"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm('ruleForm')">保 存</el-button>
              <el-button @click="dialogVisible = false">取消</el-button>
            </el-form-item>
          </el-form>
        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
    import {
        selectParentTreeItem,
        selectSonTreeItem,
        selectRuleItem,
        deleteParentTreeItem,
        deleteSonTreeItem,
        deleteRuleItem,
        getDeductionPart,
        insertParentTreeItem,
        updateParentTreeItem,
        insertSonTreeItem,
        updateSonTreeItem,
        insertRuleItem,
        updateRuleItem
    } from '@/api/deduction'

    export default {
        data() {
            return {
                depth: 1,
                breadcrumb_array: [
                    {
                        id: '0',
                        name: '索引(点击回到上一级)：扣分目录'
                    }
                ],
                tableData: [],
                tableLoading: false,

                dialogTitle: '',
                dialogVisible: false,
                gradeByOption: [],
                ruleForm: {},
                rules: {}
            };
        },
        methods: {
            async turnTo(item, index){
                this.tableLoading = true;
                if(index == 0 || index == 1){
                    await this.get_depth_once_and_second(item.id);
                }
                if(index == 2){
                    await this.get_depth_third(item.id);
                }
                if(index == 3){
                    await this.get_depth_fourth(item.id);
                }
                this.depth = index + 1;
                this.breadcrumb_array.splice(index+1, this.breadcrumb_array.length - index -1);
            },
            async open(row){
                this.tableLoading = true;
                this.depth++;
                if(this.depth == 1 || this.depth == 2){
                    await this.get_depth_once_and_second(row.id);
                }
                if(this.depth == 3){
                    await this.get_depth_third(row.id);
                }
                if(this.depth == 4){
                    await this.get_depth_fourth(row.id);
                }
                this.breadcrumb_array.push(
                    {
                        id: row.id,
                        name: row.catalogName,
                        ruleType: row.ruleType
                    }
                )
            },
            edit(row){
                let data = JSON.parse(JSON.stringify(row));
                this.dialogTitle = '编辑';
                if(this.depth == 1){
                    data.maxScore = data.maxScore/100;
                    data.minScore = data.minScore/100;
                    this.rules = {
                        maxScore: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ]
                    }
                }
                if(this.depth == 2){
                    data.maxScore = data.maxScore/100;
                    data.minScore = data.minScore/100;
                    this.rules = {
                        catalogName: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        maxScore: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        minScore: [
                            { required: true, message: '请输入默认分值', trigger: 'blur' },
                        ],
                        optFlg: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                    }
                }
                if(this.depth == 3){
                    this.rules = {
                        gradeItem: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        maxScore: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        minScore: [
                            { required: true, message: '请输入默认分值', trigger: 'blur' },
                        ],
                        gradeBy: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        ruleType: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        cycle: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                    }
                }
                if(this.depth == 4){
                    data.score = data.score/100;
                    this.rules = {
                        optionName: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        score: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        optFlg: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        countType: [
                            { type: 'string', required: true, message: '请选择计分方式', trigger: 'change' }
                        ],
                    }
                }
                this.ruleForm = data;
                this.dialogVisible = true;
            },
            del(row){
                this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    if(this.depth == 1 || this.depth == 2){
                        deleteParentTreeItem({id: row.id}).then((res) => {
                            if (res.code != "200") {
                                this.$message({
                                    message: res.msg,
                                    type: 'warning'
                                });
                            }else{
                                this.$message({
                                    type: 'success',
                                    message: res.msg,
                                });
                                this.refresh_data();
                            }
                        }).catch(() => {
                            this.tableLoading = false;
                        })
                    }
                    if(this.depth == 3){
                        deleteSonTreeItem({id: row.id}).then((res) => {
                            if (res.code != "200") {
                                this.$message({
                                    message: res.msg,
                                    type: 'warning'
                                });
                            }else{
                                this.$message({
                                    type: 'success',
                                    message: res.msg,
                                });
                                this.refresh_data();
                            }
                        }).catch(() => {
                            this.tableLoading = false;
                        })
                    }
                    if(this.depth == 4){
                        deleteRuleItem({id: row.id}).then((res) => {
                            if (res.code != "200") {
                                this.$message({
                                    message: res.msg,
                                    type: 'warning'
                                });
                            }else{
                                this.$message({
                                    type: 'success',
                                    message: res.msg,
                                });
                                this.refresh_data();
                            }
                        }).catch(() => {
                            this.tableLoading = false;
                        })
                    }
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
            add(){
                this.dialogTitle = '新增';
                if(this.depth == 2){
                    this.ruleForm = {
                        catalogName: '',
                        maxScore: '',
                        minScore: '',
                        optFlg: '',
                        catalogLevel: this.depth,
                        pid: this.breadcrumb_array[this.breadcrumb_array.length-1].id,
                    }
                    this.rules = {
                        catalogName: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        maxScore: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        minScore: [
                            { required: true, message: '请输入默认分值', trigger: 'blur' },
                        ],
                        optFlg: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                    }
                }
                if(this.depth == 3){
                    this.ruleForm = {
                        gradeItem:'',
                        gradeBy: '',
                        ruleType: '',
                        catalogId: this.breadcrumb_array[this.breadcrumb_array.length-1].id,
                        minScore: '',
                        maxScore: '',
                        cycle: ''
                    }
                    this.rules = {
                        gradeItem: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        maxScore: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        minScore: [
                            { required: true, message: '请输入默认分值', trigger: 'blur' },
                        ],
                        gradeBy: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        ruleType: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        cycle: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                    }
                }
                if(this.depth == 4){
                    this.ruleForm = {
                        gradeStandardId: this.breadcrumb_array[this.breadcrumb_array.length-1].id,
                        ruleType: this.breadcrumb_array[this.breadcrumb_array.length-1].ruleType,
                        optionName: '',
                        optFlg: '',
                        score: '',
                        countType: 'sum'
                    }
                    this.rules = {
                        optionName: [
                            { required: true, message: '请输入扣分项名称', trigger: 'blur' },
                        ],
                        score: [
                            { required: true, message: '请输入最大分值', trigger: 'blur' },
                        ],
                        optFlg: [
                            { type: 'string', required: true, message: '请选择考核类型', trigger: 'change' }
                        ],
                        countType: [
                            { type: 'string', required: true, message: '请选择计分方式', trigger: 'change' }
                        ],
                    }
                }
                this.dialogVisible = true;
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                       let data = JSON.parse(JSON.stringify(this.ruleForm));
                       if(this.depth == 1 || this.depth == 2){
                           data.maxScore = data.maxScore*100;
                           if(this.depth == 2 && data.optFlg == '#'){
                               data.minScore = '0';
                           }else{
                               data.minScore = data.minScore*100;
                           }
                           if(this.ruleForm.id != undefined){
                               updateParentTreeItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }else{
                               insertParentTreeItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }
                       }
                       if(this.depth == 3){
                           data.maxScore = data.maxScore*100;
                           data.minScore = data.minScore*100;
                           if(this.ruleForm.id != undefined){
                               updateSonTreeItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }else{
                               insertSonTreeItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }
                       }
                       if(this.depth == 4){
                           data.score = data.score*100;
                           if(this.ruleForm.id != undefined){
                               updateRuleItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }else{
                               insertRuleItem(data).then((res) => {
                                   if (res.code != "200") {
                                       this.$message({
                                           message: res.msg,
                                           type: 'warning'
                                       });
                                   }else{
                                       this.$message({
                                           type: 'success',
                                           message: res.msg,
                                       });
                                       this.refresh_data();
                                   }
                                   this.dialogVisible = false;
                               }).catch(() => {
                                   this.dialogVisible = false;
                               })
                           }
                       }
                    } else {
                        return false;
                    }
                });
            },
            refresh_data(){
                if(this.depth == 1 || this.depth == 2){
                    this.get_depth_once_and_second(this.breadcrumb_array[this.depth-1].id);
                }
                if(this.depth == 3){
                    this.get_depth_third(this.breadcrumb_array[this.depth-1].id);
                }
                if(this.depth == 4){
                    this.get_depth_fourth(this.breadcrumb_array[this.depth-1].id);
                }
            },
            get_depth_once_and_second(id){
                selectParentTreeItem({pid: id}).then((res) => {
                    if (res.code != "200") {
                        this.$message({
                            message: res.msg,
                            type: 'warning'
                        });
                        this.tableLoading = false;
                    }else{
                        this.tableData = res.data;
                        this.tableLoading = false;
                    }
                }).catch(() => {
                    this.tableLoading = false;
                })
            },
            get_depth_third(id){
                selectSonTreeItem({catalogId: id}).then((res) => {
                    if (res.code != "200") {
                        this.$message({
                            message: res.msg,
                            type: 'warning'
                        });
                        this.tableLoading = false;
                    }else{
                        console.log(res);
                        this.tableData = res.data;
                        this.tableLoading = false;
                    }
                }).catch(() => {
                    this.tableLoading = false;
                })
            },
            get_depth_fourth(id){
                selectRuleItem({gradeStandardId: id}).then((res) => {
                    if (res.code != "200") {
                        this.$message({
                            message: res.msg,
                            type: 'warning'
                        });
                        this.tableLoading = false;
                    }else{
                        this.tableData = res.data;
                        this.tableLoading = false;
                    }
                }).catch(() => {
                    this.tableLoading = false;
                })
            },
            getDeductionPart(){
                getDeductionPart({}).then((res) => {
                    if (res.code != "200") {
                        this.$message({
                            message: res.msg,
                            type: 'warning'
                        });
                    }else{
                        this.gradeByOption = res.data;
                    }
                }).catch(() => {
                    this.tableLoading = false;
                })
            }
        },
        created(){
            this.refresh_data();
            this.getDeductionPart();
        }
    }
</script>
<style lang="scss">
  #deduction_all {
    #top_box {
      margin: 10px 20px 10px 20px;
    }
    #tree_box {
      margin: 10px 20px 10px 20px;
    }
  }
</style>
